package com.hluck.mvidemo.ui.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.hluck.mvidemo.data.repository.MainRepository
import com.hluck.mvidemo.network.ApiService

/**
 *
 * @Author： LJH
 * @Time： 2023/10/9
 * @description：
 */
class ViewModelFactory(private val apiService: ApiService):ViewModelProvider.Factory {
    override fun <T : ViewModel> create(modelClass: Class<T>): T {
        if(modelClass.isAssignableFrom(MainViewModel::class.java)){
            return MainViewModel(MainRepository(apiService)) as T
        }
        throw IllegalArgumentException("UnKnow class")
    }
}